# Contributor: TBK <alpine@jjtc.eu>
# Maintainer: TBK <alpine@jjtc.eu>
pkgname=nebula
pkgver=1.9.1
pkgrel=2
pkgdesc="Scalable overlay networking tool with a focus on performance, simplicity and security"
url="https://github.com/slackhq/nebula"
license="MIT"
# tests seem to fail due to >32-bit allocs, probably doesn't work
# s390x: service_test timed out
arch="all !x86 !armhf !armv7 !s390x"
pkgusers="$pkgname"
pkggroups="$pkgname"
install="$pkgname.pre-install"
makedepends="go"
subpackages="$pkgname-openrc"
source="https://github.com/slackhq/nebula/archive/v$pkgver/nebula-$pkgver.tar.gz
	unset-CGO_ENABLED.patch
	$pkgname.initd
	"

# secfixes:
#   1.8.1-r0:
#     - CVE-2023-48795

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	make BUILD_ARGS="$GOFLAGS" BUILD_NUMBER="$pkgver" bin
}

check() {
	make test
}

package() {
	install -Dm750 -o nebula -g nebula nebula -t "$pkgdir"/usr/sbin/

	install -Dm755 nebula-cert -t "$pkgdir"/usr/bin/

	install -Dm644 examples/config.yml -t "$pkgdir"/etc/$pkgname

	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
}

sha512sums="
4ba2a809717bdf8fc733b81648e235331e3b8112dfcc5de9b71eed920000af1d843f0f1ea4f255c9f4a834e5a9000cecd1543b43bb7c777e6118136c031591dd  nebula-1.9.1.tar.gz
0db0013e3cecb761c89c92ddd1a2a58d7630673b47d387f7c0c757987d5aa8d9b0f21ffa462ebec814c821bfe3b19b026941414950681c560239d479f9893ae6  unset-CGO_ENABLED.patch
b86a38a0e558f2bc00b062d713cd3ad3e6b5e7a0695c92d7bfe5633edb80184fcd64ebf5af6c35677c91719159dad8cd38c2278b5f4d9f5d2e42f101e6e354b2  nebula.initd
"
